package com.dpj.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/axiosServlet")
public class AxiosServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 设置响应数据的中文乱码
        response.setContentType("text/html;charset=utf-8");
        // 设置请求参数的中文乱码
        request.setCharacterEncoding("utf-8");
        System.out.println("get");
        String username = request.getParameter("username");
        System.out.println(username);

        response.getWriter().write("hello Axios");

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("post");
        doGet(request, response);
    }
}
